package DuiXiang.src.Computer;

import java.util.Scanner;

public class ComputerTest {
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        Computer c = new Computer("联想S436", "红色", "1024*768");
        while (true) {
            System.out.println("1.格式化；2.安装操作系统；3.启动；4.安装软件；5.下载软件；6.查看各盘情况；9、关机；0.退出");
            int ch = input.nextInt();
            if (ch == 1) {
                if (c.isStart1()) {
                    System.out.println("计划分几个盘;");
                    int a = input.nextInt();
                    for (int i = 0; i < a; i++) {
                        Disk d = new Disk();
                        System.out.println("请输入" + (i + 1) + "个盘符名称和大小：");
                        d.setName(input.next());
                        d.setDiskSize(input.nextDouble());
                        c.format(d);
                    }
                    System.out.println("格式化成功！");
                } else {
                    System.out.println("请先启动电脑。");
                }
            } else if (ch == 2) {
                if (c.isStart1() && c.isFormat1()) {
//                    boolean a = true;
//                    while (a) {
                        System.out.println("请选择需要安装的操作系统\nwin7_700M / win10_800M / win11_1000M");
                        String os = input.next();
                        System.out.println("请选择安装的盘：");
                        String p = input.next();
                        if (c.os(os, p)) {
//                            a = false;
                            System.out.println("安装成功！");
                        } else {
                            System.out.println("安装失败！");
                        }
  //                  }
                } else if (!c.isFormat1() && c.isStart1())
                    System.out.println("请先格式化电脑");
                else
                    System.out.println("请先启动电脑并格式化");
            } else if (ch == 3) {
                c.start();
            } else if (ch == 4) {
                if (c.isStart1() && c.isFormat1() && c.isOs1()) {
                    Software s = new Software();
                    System.out.println("1、普通软件；2、下载软件");
                    int a = input.nextInt();
                    System.out.println("软件名称：");
                    s.setName(input.next());
                    System.out.println("软件大小（M）：");
                    s.setMemory(input.nextInt());
                    System.out.println("安装位置：");
                    String n = input.next();
                    if (c.add(n, s)) {
                        System.out.println("安装成功");
                    } else {
                        System.out.println("安装失败");
                    }
                } else if (!c.isFormat1() && c.isStart1())
                    System.out.println("请先格式化电脑");
                else if (!c.isOs1() && c.isFormat1())
                    System.out.println("请先安装操作系统");
                else
                    System.out.println("请先启动电脑");
            } else if (ch == 5) {
            } else if (ch == 6) {
                if (c.isStart1() && c.isFormat1() && c.isOs1()) {
                    System.out.println("请选择需要查看的盘符：");
                    c.showDisk(input.next());
                } else if (!c.isFormat1() && c.isStart1())
                    System.out.println("请先格式化电脑");
                else if (!c.isOs1() && c.isFormat1())
                    System.out.println("请先安装操作系统");
                else
                    System.out.println("请先启动电脑");
            } else if (ch == 9) {
                System.out.println("关机");
                c.shutDown();
            } else if (ch == 0) {
                System.out.println("退出");
                return;
            }
        }
    }
}
